package com.alks.yn_zs.data.vo;

import com.alks.yn_zs.data.dto.FinishStoreDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author: chen
 * @date: 2024/11/22
 * @description: 库存DTO
 */
@Data
@ApiModel(value = "库存DTO")
public class FinishStoreVO {

    private String companyId;

    @ApiModelProperty(value = "品牌")
    private String custom;

    @ApiModelProperty(value = "指令号")
    private String lotNo;

    @ApiModelProperty(value = "订单数量")
    private Long orderQty;

    @ApiModelProperty(value = "欠数")
    private Long lackQty;

    @ApiModelProperty(value = "库存数")
    private Long storeQty;

    public static FinishStoreVO convert(FinishStoreDTO dto) {
        FinishStoreVO vo = new FinishStoreVO();
        vo.setCompanyId(dto.getCompanyId());
        vo.setCustom(dto.getCustom());
        vo.setLotNo(dto.getLotNo());
        vo.setOrderQty(dto.getOrderQty());
        if (dto.getOrderQty() == null) {
            return vo;
        }
        if (dto.getInQty() != null) {
            vo.setLackQty(dto.getOrderQty() - dto.getInQty());
            if (dto.getOutQty() != null) {
                vo.setStoreQty(dto.getInQty() - dto.getOutQty());
            }
        }
        return vo;
    }
}
